/*
 moxl - Modular XML Library
 Copyright (c) 2007, Malcolm Sparks

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package moxl.parser.markup;

import java.io.IOException;
import java.io.InputStream;

import moxl.parser.ParserException;
import moxl.reader.Location;
import moxl.reader.XmlReader;
import moxl.tokenizer.TokenStream;
import moxl.tokenizer.Tokenizer;
import moxl.tokenizer.xml.document.DocumentStartState;

public class MarkupParser
{
	public MarkupStream parse(String s) throws ParserException, IOException
	{
		return parse(new XmlReader(s));
	}

	public MarkupStream parse(InputStream in) throws ParserException
	{
		try
		{
			return parse(new XmlReader(in));
		}
		catch (IOException e)
		{
			throw new ParserException("Failed to initialize XmlReader", new Location(), e);
		}
	}

	public MarkupStream parse(XmlReader reader)
	{
		return parse(new Tokenizer(reader, DocumentStartState.getInstance()));
	}

	protected MarkupStream parse(Tokenizer tokenizer)
	{
		return parse(new TokenStream(tokenizer));
	}

	protected MarkupStream parse(TokenStream tstream)
	{
		return new MarkupStream(tstream);
	}
}
